package com.microservice.microserviceuser.controller;

import com.microservice.microserviceuser.entity.User;
import org.springframework.web.bind.annotation.*;

import java.util.Random;

/**
 * Created by bf on 2017/11/11.
 */
@RestController
@RequestMapping
public class UserController {

    @GetMapping(value = {"/user/{id}"})
    public String getId(@PathVariable Long id) throws InterruptedException {
/*        Random r = new Random();
        int i = r.nextInt(3000);

        Thread.sleep(i);*/

        System.out.println(" enter method ！！！");
        return "USER 服务 id: " + id;

    }

    @GetMapping(value = "/getuser/{id}")
    public User getUser(@PathVariable Long id){
        System.out.println("enter method id: " + id);
        User user = new User();
        user.setId(id);
        user.setNickname("nickname: " + id);
        user.setUsername("username: " + id);
        return user;
    }

    @PostMapping(value = "/postuser")
    public User postUser(@RequestBody User user){
        return user;
    }

    @PostMapping(value = "/get-user")
    public User getTest(@RequestBody User user){
        return user;
    }

}
